//
//  ByUIAppIndexVC.m
//  chequanbao_ios
//
//  Created by pro on 17/5/6.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByUIAppIndexVC.h"

// service
#import "ByCoreToolLocation.h"              // 定义服务

// vc
#import "ByUIIndexLocationVC.h"             // 定位
#import "ByUIShopsIndexVC.h"                // 商家
//#import "ByUISafetyIndexVC.h"               // 保险
#import "ByUIPropertySafetyVC.h"
#import "ByUIStoreIndexVC.h"                // 商城
#import "ByUIAppIndexDevelopenttVC.h"
#import "ByUIMineWelfareVC.h"               // 我的福利
#import "ByUIAppIndexMoreVC.h"              // 更多美好
#import "ByUIShopsNewIndexVC.h"             // 联盟商家

// view
#import "ByViewDetailHeaderCarousel.h"      // 轮播视图
#import "ByViewRedPicket.h"                 // 红包
#import "ByViewLocation.h"                  // 导航

// api
#import "ByApiAppIndex.h"

// model
#import "ByModelIndexCarousel.h"

@interface ByUIAppIndexVC () <ByCoreLoactionDelegate>

@property (nonatomic, strong) UIScrollView                  *scroll;          // 底部滑动视图

@property (nonatomic, strong) UIView                        *locationView;    // 定位
@property (nonatomic, strong) ByViewDetailHeaderCarousel    *carousel_top;    // 轮播
//@property (nonatomic, strong) ByViewDetailHeaderCarousel    *carousel_bottom; // 轮播

@property (nonatomic, strong) ByViewRedPicket               *rpView;          // 红包
@property (nonatomic, strong) ByViewLocation                *dhView;          // 导航
@end

@implementation ByUIAppIndexVC
{
    NSString *_city;            // 定位城市或者选择城市
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"首页";
    
    // 展示红包
    [self needShowRedPacket];
    
    [self addBYItemviews:@[@"定位"] mode:ByNavigationItemModeText position:ByNavigationItemPositionModeLeft];
    [self addBYItemviews:@[@"Index_daohang"] mode:ByNavigationItemModeImage position:ByNavigationItemPositionModeRight];
    [self createCityLocationView];
    [self createCarousel_top];
    [self createFuncationView];
    [self createOtherView];

    NSLog(@"%lf",self.scroll.subviews.lastObject.bottom);
    self.scroll.contentSize = CGSizeMake(0, self.scroll.subviews.lastObject.bottom);
    
    // 定位
    [self location];
    
 
}
- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];
    [self setNaviAttributeWithTranslucent:YES stateBarLightContent:YES];
    // 获取轮播
    [self getCarousel];
//    [self getCarousel2];
}

- (void)viewSafeAreaInsetsDidChange{
    [super viewSafeAreaInsetsDidChange];
    self.scroll.top = self.view.safeAreaInsets.top;
    self.scroll.height = self.view.height - self.view.safeAreaInsets.bottom;
}

- (void)rightItemsAction:(NSInteger)rightIndex{
    [self.dhView show];
}

#pragma mark - 懒加载
- (UIScrollView *)scroll {
    
    if (!_scroll) {
        _scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 49 - 64)];
        _scroll.bounces = NO;
        _scroll.showsVerticalScrollIndicator = NO;
        [self.view addSubview:_scroll];
    }
    return _scroll;
}
- (ByViewRedPicket *)rpView {
    
    if (!_rpView) {
        _rpView = [[ByViewRedPicket alloc] init];
        __weak typeof(self) wself = self;
        _rpView.rpTapBlock = ^ {
            
            [wself by_normalPush:[ByUIMineWelfareVC new] hasNavi:YES];
        };
    }
    return _rpView;
}

- (ByViewLocation *)dhView{
    if (!_dhView) {
        _dhView = [[ByViewLocation alloc] init];
        __weak typeof(self) wkself = self;
        _dhView.clickBlock = ^(NSInteger index) {
            if (index == 0) {
                [wkself baiduMap];
            }else{
                [wkself gaodeMap];
            }
        };
        
    }
    return _dhView;
}

#pragma mark - 导航
// 百度地图
- (void)baiduMap{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]])// -- 使用 canOpenURL 判断需要在info.plist 的 LSApplicationQueriesSchemes 添加
    {
//        double latitude =self.coordinate.latitude;
//        double longitude =self.coordinate.longitude;
        NSString *urlString = @"baidumap://map";
        urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSURL *mapUrl = [NSURL URLWithString:urlString];
        [[UIApplication sharedApplication] openURL:mapUrl];
        
        
        
    }else{
        
        [[[UIAlertView alloc]initWithTitle:@"没有安装百度地图" message:@"" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil, nil] show];
    }
}

// 高德地图
- (void)gaodeMap{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
        NSString *urlString = @"iosamap://path";
        urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSURL *mapUrl = [NSURL URLWithString:urlString];
        [[UIApplication sharedApplication] openURL:mapUrl];
        
    }else{
        
        [[[UIAlertView alloc]initWithTitle:@"没有安装高德地图" message:@"" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
    }
}

#pragma mark - 定位
- (void)location {
    
    [ByCoreToolAlert showLoadind:@"正在定位..."];
    ByCoreToolLocation *locationManager = [ByCoreToolLocation shareInstance];
    locationManager.delegate = self;
    [locationManager configLocationService];
    [locationManager startUpdateLoaction];
}
- (void)locationDidComplete:(NSDictionary *)placeInfoDic {
    
    [ByCoreToolAlert hideHud];
    
    // 更新当前显示的城市
    _city = placeInfoDic[@"city"];
    [self updateLocation];

    // 设置定位城市
    BY_APPDELEGATE.locationCity = _city;
    BY_APPDELEGATE.locationDic = placeInfoDic;
    
}
- (void)locationDidFail:(NSError *)error {
    [ByCoreToolAlert showOnlyText:@"定位失败"];
}
- (void)updateLocation {
    
    UILabel *cityLabel = [self.locationView viewWithTag:2];
    cityLabel.text = _city;
}

#pragma mark - 网络请求
// 轮播
- (void)getCarousel {
    
    ByNetParamsModel *params = [ByNetParamsModel new];
    params.position = @"6079";
    
    [ByApiAppIndex getIndexCarousel:params success:^(ByNetBaseResult *result) {
        
        NSArray<ByModelIndexCarousel *> *carousels = result.data;
        NSMutableArray *imageUrlStrs = [NSMutableArray new];
        [carousels enumerateObjectsUsingBlock:^(ByModelIndexCarousel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [imageUrlStrs addObject:BOYE_PICTURE_VIEW_URL(obj.img)];
        }];
        
        self.carousel_top.imageURLStringDatas = imageUrlStrs.copy;
        
    } failure:^(ByNetBaseResult *result) {
        self.carousel_top.imageURLStringDatas = @[@"default"];
        [ByCoreToolAlert showFailureWithText:@"轮播图获取失败"];
    }];
}
//// 轮播
//- (void)getCarousel2 {
//    
//    ByNetParamsModel *params = [ByNetParamsModel new];
//    params.position = @"6243";
//    
//    [ByApiAppIndex getIndexCarousel:params success:^(ByNetBaseResult *result) {
//        
//        NSArray<ByModelIndexCarousel *> *carousels = result.data;
//        NSMutableArray *imageUrlStrs = [NSMutableArray new];
//        [carousels enumerateObjectsUsingBlock:^(ByModelIndexCarousel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//            [imageUrlStrs addObject:BOYE_PICTURE_VIEW_URL(obj.img)];
//        }];
//        
//        self.carousel_bottom.imageURLStringDatas = imageUrlStrs.copy;
//        
//    } failure:^(ByNetBaseResult *result) {
//        self.carousel_bottom.imageURLStringDatas = @[@"default"];
//
//        [ByCoreToolAlert showFailureWithText:@"轮播图获取失败"];
//    }];
//}


#pragma mark - create views
// 创建导航栏视图
- (void)createCityLocationView {
    
    self.locationView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH * 0.2, 30)];
    self.locationView.backgroundColor = [UIColor clearColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(locationTap:)];
    [self.locationView addGestureRecognizer:tap];
    
    UIImageView *downIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
    downIcon.image = [UIImage imageNamed:@"Index_jiantou_down"];
    [self.locationView addSubview:downIcon];
    downIcon.right = self.locationView.width - 10;
    downIcon.y = self.locationView.height / 2;
    downIcon.tag = 1;
    
    UILabel *cityLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, downIcon.left, self.locationView.height)];
    cityLabel.font = FONT(14);
    cityLabel.text = @"选择";
    cityLabel.textColor = [UIColor whiteColor];
    cityLabel.textAlignment = NSTextAlignmentCenter;
    [self.locationView addSubview:cityLabel];
    cityLabel.tag = 2;
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:self.locationView];
    self.navigationItem.leftBarButtonItem = leftItem;
}
- (void)createCarousel_top {
    
    self.carousel_top = [[ByViewDetailHeaderCarousel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 2) timerDuration:3];
    [self.scroll addSubview:self.carousel_top];
}
//- (void)createCarousel_bottom {
//    
//    self.carousel_bottom = [[ByViewDetailHeaderCarousel alloc] initWithFrame:CGRectMake(10, self.scroll.subviews.lastObject.bottom + 12, SCREEN_WIDTH - 20, SCREEN_WIDTH / 2) timerDuration:3];
//    [self.scroll addSubview:self.carousel_bottom];
//}

- (void)createFuncationView {
    
    CGFloat x, y, width, height;
//    CGFloat margin = 12;
    
//    NSArray *images = @[@"Index_shangjia",
//                        @"Index_baoxian",
//                        @"Index_shangcheng",
//                        @"Index_fanggong",
//                        @"Index_jinrong",
//                        @"Index_yanglao",
//                        @"Index_dingzhi",
//                        @"Index_gongyi"];
    NSArray *images = @[@"Index_shangjia",
                        @"Index_baoxian",
                        @"Index_shangcheng",
                        @"Index_dingzhi",
                        ];

//    NSArray *texts = @[@"商  家",
//                       @"保  险",
//                       @"商  城",
//                       @"房  供",
//                       @"金  融",
//                       @"养  老",
//                       @"定  制",
//                       @"公  益",
//                       ];
    NSArray *texts = @[@"联盟商家",
                       @"有车一族",
                       @"商城",
                       @"定制",
                       ];
//    for (int i = 0; i < texts.count; i ++) {
//        width = (SCREEN_WIDTH - 3 * margin) / 2;
//        height = width / 335 * 160;
//        x = margin + (i % 2) * (width + margin);
//        y = self.carousel_top.bottom + margin + (i / 2) * (height + margin);
//        UIControl *view = [self createHorizontalModeView:CGRectMake(x, y, width, height)
//                                               imageSize:CGSizeMake(height * 0.5, height * 0.5)
//                                               imageName:images[i]
//                                                textFont:FONT(18)
//                                                    text:texts[i]
//                                                  margin:10];
//        view.layer.cornerRadius = 4;
//        view.tag = 1 + i;
//        [self.scroll addSubview:view];
//        
//        
//        [view addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
//    }
    
    CGFloat m_h, m_v;
    m_h = 10;
    m_v = 10;

    for (int i = 0; i < texts.count; i ++) {
        width = (SCREEN_WIDTH - 3 * m_h) / 2;
        height = width / 335 * 160;
        x = m_h + (i % 2) * (width + m_h);
        y = self.carousel_top.bottom + m_v + (i / 2) * (height + m_v);
        UIControl *view = [self createHorizontalModeView:CGRectMake(x, y, width, height)
                                               imageSize:CGSizeMake(height * 0.5, height * 0.5)
                                               imageName:images[i]
                                                textFont:FONT(18)
                                                    text:texts[i]
                                                  margin:7];
        view.layer.cornerRadius = 4;
        view.tag = 1 + i;
        [self.scroll addSubview:view];
        
        
        [view addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    
}

- (void)createOtherView {
    
    CGFloat x, y, width, height, margin = 10;
    x = margin;
    y = self.scroll.subviews.lastObject.bottom + margin;
    width = self.scroll.width - margin * 2;
    height = width / 690 * 160;
    // 1.创建基底视图
    UIControl *basalView = [[UIControl alloc] initWithFrame:CGRectMake(x, y, width, height)];
    basalView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];
    basalView.layer.cornerRadius = 4;
    [self.scroll addSubview:basalView];
    basalView.tag = 100;
    [basalView addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];

//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:basalView.bounds];
//    imageView.image = [UIImage imageNamed:@"Index_gengduo"];
//    [basalView addSubview:imageView];
//    
//    // 2.创建图片
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, height / 2, height / 2)];
//    imageView.image = [UIImage imageNamed:@""];
//    [basalView addSubview:imageView];
    
    // 3.创建文字
    UIFont *font = FONT(16);
    NSString *text = @"更多美好";
//    CGFloat fontSize = [font pointSize];
//    width = [text getSizeOfString:fontSize].width + 2; // 防止iOS10以上不适配
    width = basalView.width;
    height = basalView.height;
    x = 0;
    y = 0;
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
    textLabel.font = font;
    textLabel.text = text;
    textLabel.textColor = [UIColor whiteColor];
    textLabel.textAlignment = NSTextAlignmentCenter;
    [basalView addSubview:textLabel];
    
//    CGFloat remain = (basalView.width - imageView.width - textLabel.width - margin) / 2;
//    // 4.适配距离
//    imageView.left = remain;
//    imageView.y = basalView.height / 2;
//    textLabel.left = imageView.right + margin;
//    textLabel.y = basalView.height / 2;
}

// 创建水平排版的视图（可点击）
- (UIControl *)createHorizontalModeView:(CGRect)frame
                              imageSize:(CGSize)size
                              imageName:(NSString *)name
                               textFont:(UIFont *)font
                                   text:(NSString *)text
                                 margin:(CGFloat)margin {
    
    // 1.创建基底视图
    UIControl *basalView = [[UIControl alloc] initWithFrame:frame];
    basalView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];

    
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:basalView.bounds];
//    imageView.image = [UIImage imageNamed:name];
//    [basalView addSubview:imageView];
    
    // 2.创建图片
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
    imageView.image = [UIImage imageNamed:name];
    [basalView addSubview:imageView];

    
    // 3.创建文字
    CGFloat fontSize = [font pointSize];
    CGFloat width = [text getSizeOfString:fontSize].width + 2; // 防止iOS10以上不适配
    CGFloat height = basalView.height;
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, height)];
    textLabel.numberOfLines = 0;
    textLabel.font = font;
    textLabel.text = text;
    textLabel.textColor = [UIColor whiteColor];
    textLabel.textAlignment = NSTextAlignmentCenter;
    [basalView addSubview:textLabel];
    
    // 4.适配距离
    imageView.right = basalView.width / 2 - 20;
    imageView.y = basalView.height / 2;
    textLabel.left = imageView.right + margin;
    textLabel.y = basalView.height / 2;
    
    return basalView;
}

#pragma mark - 逻辑
// 是否需要展示红包
#define KIsFirstUse @"isFirstUse"
- (BOOL)needShowRedPacket {
    
    NSNumber *isFirstUse = [ByCoreCacheSqlite3 getValueWithKey:KIsFirstUse];
    // 没有设置过值，就说明是第一次
    if ( isFirstUse == nil) {
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            dispatch_after(dispatch_time(0, NSEC_PER_SEC * 0.5), dispatch_get_main_queue(), ^{
                [self.rpView show];
            });
        });
        [ByCoreCacheSqlite3 setObjectWithKey:KIsFirstUse value:@YES];
        return YES;
    } else {
        return NO;
    }
    
}


#pragma mark - 点击事件
- (void)tapAction:(UIControl *)sender {
    
    
    switch (sender.tag) {
        case 1:
        {
//            ByUIShopsIndexVC *vc = [[ByUIShopsIndexVC alloc] init];
            ByUIShopsNewIndexVC *vc = [[ByUIShopsNewIndexVC alloc] init];
            [self by_normalPush:vc hasNavi:YES];
        }
            break;
        case 2:
        {
            if (!BY_USER) {
                ByUILoginVC *vc = [[ByUILoginVC alloc] init];
                ByBaseNaviController *navi = [[ByBaseNaviController alloc] initWithRootViewController:vc];
                [self presentViewController:navi animated:YES completion:nil];
                return;
            }
//            ByUISafetyIndexVC *vc = [[ByUISafetyIndexVC alloc] init];
//            [self by_normalPush:vc hasNavi:YES];
            ByUIPropertySafetyVC *vc = [[ByUIPropertySafetyVC alloc] init];
            [self by_normalPush:vc hasNavi:YES];
        }
            break;
        case 3:
        {
            ByUIStoreIndexVC *vc = [[ByUIStoreIndexVC alloc] init];
            [self by_normalPush:vc hasNavi:YES];
        }
            break;
//        case 4:
//        {
//            ByUIAppIndexDevelopenttVC *vc = [[ByUIAppIndexDevelopenttVC alloc] initWithTitle:@"房供少一分 幸福多一份" imageName:@"Index_dev_fanggong" content:@"        中国财经网报道，2015年，中国居民家庭每年负担的房贷还款金额占家庭可支配收入的 28%，预计2017年结束，这个数字将超过40%。也就是说，假设购房者家庭每月收入是8000元，那么将有3200元用来还房贷，加之有些地区贷款利率的优惠政策已经不再提供，购房者的还贷压力可想而知，此外日常生活开支、小孩教育支出、人情来往随礼等，使得普通家庭生活资金很难有结余，由房贷引发的青、中年人潜在的生活危机已不容小觑。\n        以民生幸福为奋斗宗旨，这是江苏掌握信息科技项目创始人黄锋的创业信条，其独创的“消费红利主动增值和再次分配”模式始终秉承这一宗旨，为广大背负房贷压力的社会群体带来福音，会员在掌握平台所有联盟商家消费享受优惠折扣的同时可额外获得相应比例的消费分红。如您去掌握平台某个联盟饭店消费1000元（已经是折扣价），那么您此次获得消费分红1000*5%/2=25元，这25元即可进入您的账户并且通过不断累积可直接用于还房供。通过长期累积的消费分红来缓解家庭生活还供压力，既能正常生活消费支出，又能额外获得房供补贴，何乐而不为。\n        江苏掌握信息科技，助您房供少一份，伴您幸福多一分。" bottomImgName:nil];
//            [self by_normalPush:vc hasNavi:YES];
//        }
//            break;
//        case 5:
//        {
//            ByUIAppIndexDevelopenttVC *vc = [[ByUIAppIndexDevelopenttVC alloc] initWithTitle:@"消费分红天天有 余额增值日日升" imageName:@"Index_dev_licai" content:@"        理财是人们在不确定环境中进行资源跨期的最优配置决策的行为，是对现有资源进行重新整合，实现价值和利润的等效流通。随着经济生活水平的提高，随之带来的生活压力使很多人慢慢学会精打细算，理财渐渐成为越来越多人的生活内容，从银行存钱到花钱炒股，都是期望获得额外的经济收入。何时能够不敲着算盘过日子、不在乎股票涨停、任性的坐等收入？\n        江苏掌握信息科技项目创始人黄锋独创的“消费红利主动增值及再次分配”模式就是最好的懒人理财，只要有消费，就会有分红；消费越多，所获分红越大；如您去掌握平台联盟饭店消费1000元（已经是折扣价），那么您此次获得消费分红1000*5%/2=25元，这25元即可进入您的账户，每次消费红利均可累积，有消费就有分红并且可增值，日积月累便是财富，这样的理财能实实在在看到结果，让理财变成一件容易到无需学习的事。\n        江苏掌握信息科技，伴您余额增值日日升。" bottomImgName:nil];
//            [self by_normalPush:vc hasNavi:YES];
//        }
//            break;
//        case 6:
//        {
//            ByUIAppIndexDevelopenttVC *vc = [[ByUIAppIndexDevelopenttVC alloc] initWithTitle:@"幸福养老 自己掌握" imageName:@"Index_dev_yanglao" content:@"        截至2016年底，我国60岁以上人口已达2.3亿人，占总人口的16.7%，即每5人（包括未成年人）之中就有1位老人，中年人普遍表示养老压力大，传统养儿防老的观念已无力维持。我国人口老龄化呈现的总量大、速度快、不平衡的特点，对养老、医疗保险等制度的可持续发展带来重大挑战，为此，国家在十三五规划中指明迫切需要创新发展机制，鼓励社会、企业、家庭及个人积极参与养老服务，承担时代发展的责任。由此，江苏掌握信息科技项目创始人黄锋独创的“消费红利主动增值和再次分配“的消费分红养老模式应运而生。\n        消费分红养老，即消费者通过日常生活中产生的消费分红进行累积并可进行养老的各项活动支出。如您在掌握联盟饭店消费1000元（已经是折扣价)，享受优惠折扣的同时额外又获得平台给以的1000*5%/2=25元消费分红，并即刻进入您自己的账户，所有联盟商家消费分红均可积累并可用于养老的各项服务活动。这一举措不仅实现了消费分红的主动增值和再次分配，更缓解了广大老百姓对于养老的压力，是一项利国惠民的创新民生项目，得到了众多机构及百姓的认可。\n        消费红利养老是掌握信息科技的一项终身事业，致力于老有所依、老有所养、减轻广大子女赡养负担。守候老年人的晚年幸福，掌握所有人将为之不懈奋斗。" bottomImgName:nil];
//            [self by_normalPush:vc hasNavi:YES];
//        }
//            break;
        case 4:
        {
            ByUIAppIndexDevelopenttVC *vc = [[ByUIAppIndexDevelopenttVC alloc] initWithTitle:@"创新消费新模式 共享定制新生活" imageName:@"Index_dev_dingzhi" content:@"        生活中，能用5000元买到的东西我们绝不想花7000元的支出，如何能以最优惠的价格获得心仪的产品又不致卖方减少利润？这是一种消费新观念。作为消费者，我们的需求很多，但刚需方面大都类似，如果因为价高而放弃某些钟爱的东西，实在是惋惜。\n        为解决供需价格问题，大连掌握信息科技独创了一套提前定制商业推广模式，帮助有共同需求的会员一起来省钱，以最实惠的价格拿下心仪的产品和服务。如您想买一台30万的车，4S店告诉您这30万的价格已经是全国范围内能给到的最低折扣，但您只有22万，这时您就可以通过掌握平台发起同款类型车的购车愿意，当会员需求累计达到目标之后，掌握平台即可与汽车生产企业进行沟通，从而定制生产。一方面减少了会员消费开支，另一方面帮助生产企业去掉库存和消化原材料存贮等，创造互利共赢的良好消费生态市场，同时消费者的需求可延伸到生活方方面面的需求，掌握科技减少消费者消费负担而让生产企业获得更多利润。\n        传统的消费模式是被动接受产品，但是如果厂家提前知道消费者需求、喜好、创意等等，则会生产出专属某些群体的独创产品，供需水平达到最优化，省去中间费，消费者花更少钱，生产商赚更多钱，互惠双赢的同时打造精致生活的完美享受，共享掌握定制带来的新惊喜。\n        掌握定制，总有一款适合你。" bottomImgName:nil];
            [self by_normalPush:vc hasNavi:YES];
        }
            break;

        case 100:
        {
            ByUIAppIndexMoreVC *vc = [[ByUIAppIndexMoreVC alloc] init];
            [self by_normalPush:vc hasNavi:YES];
        }
            break;
        default:
            break;
    }
}
- (void)locationTap:(UITapGestureRecognizer *)tap {
    
    ByUIIndexLocationVC *vc = [[ByUIIndexLocationVC alloc] init];
    [self by_normalPush:vc hasNavi:YES];
    vc.locationDidSelected = ^(ByModelLocationCity *cityModel) {
        
        BY_APPDELEGATE.selectedCityModel = cityModel;
        _city = cityModel.city;
        [self updateLocation];
    };

}

@end
